home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / 386POWER.INC < prev    next >
Text File  |  1995-01-14  |  9KB  |  234 lines

  1. ; 386POWER INCLUDE FILE
  2. ; VIRTUAL 80x86 REGISTER IMAGE
  3. extrn   V86eax:dword, V86ebx:dword, V86ecx:dword, V86edx:dword
  4. extrn   V86esi:dword, V86edi:dword, V86ebp:dword
  5. extrn   V86ah:byte, V86al:byte, V86bh:byte, V86bl:byte
  6. extrn   V86ch:byte, V86cl:byte, V86dh:byte, V86dl:byte
  7. extrn   V86ax:word, V86bx:word, V86cx:word, V86dx:word
  8. extrn   V86si:word, V86di:word, V86bp:word
  9. extrn   V86ds:word, V86es:word, V86fs:word, V86gs:word
  10.  
  11. ; GLOBAL VARS
  12. extrn   _SelCode:word, _SelData:word, _SelZero:word, _LoMemBase:dword
  13. extrn   _LoMemTop:dword, _HiMemBase:dword, _HiMemTop:dword, _PSPBase:dword
  14. extrn   _Code16Base:dword, _Code32Base:dword, _OldInt:dword:256
  15.  
  16. ; _386Return is a pointer (into low memory) to the first exit message
  17. ; _386Terminator is the default  exit message
  18. extrn   _386Return:dword, _386Terminator:byte
  19.  
  20. ; protected-to-realmode entry points
  21. extrn _ExecINT:dword
  22. ;               replaces INT 33h from prot. mode
  23.  
  24. extrn _ExecReal:dword
  25. ;               replaces INT 32h from prot. mode
  26.  
  27. ; These two _GetIRQ and _SetIrq are NEAR POINTERS to the routines needed
  28. ; to set protected mode irq handlers
  29.  
  30. ; _GetIRQ:
  31. ; BL = IRQ number
  32. ; EDX = OFFSET  of the irq routine (selector is always code32)
  33. extrn _GetIRQ:dword
  34.  
  35. ; _SetIRQ:
  36. ; BL = IRQ NUMBER ( the irq line it uses, NOT the interrupt number)
  37. ;                  IRQ 0..7   == "real mode int"   8..0Fh
  38. ;                  IRQ 8..0Fh == "real mode int" 70h..77h
  39. ;
  40. ; EDX = OFFSET  of the irq routine (selector is always code32)
  41. ;
  42. ; The routine pointed by EDX is set as the new PROTECTED MODE
  43. ; handler for the IRQ.
  44. ; Usually when a "new" protected mode handler is set
  45. ; the dos-extender "places" into the real mode interrupt table
  46. ; a routine called "interrupt reflector" that redirects the
  47. ; irq handling to the protected mode handler you set.
  48. ; (this way you don't need to worry "where" the irq happens).
  49. ; The only expection to this rule is when running under VCPI (i.e EMM386)
  50. ; the VCPI server "interacts" with IRQ0 and IRQ1 in a strange way
  51. ; so the VCPI "set irq" code does not redirects those IRQs
  52. ; IF YOU WANT, call the ms-dos get/set interrupt functions (using _ExecINT)
  53. ; and set those IRQ directly.
  54. ;
  55. ; If you call _SetIRQ with EDX=default irq handler
  56. ; then the "real mode handling" is set as it was at 386P startup
  57. ; (this happens for IRQ0 and IRQ1 too!!!! So you can avoid to
  58. ;  call _ExecINT again if you took'em over yourself).
  59. extrn _SetIRQ:dword
  60.  
  61.  
  62. ; Similar to the get/set irq these routines enable or disable
  63. ; the IRQ LINE on the Programmable Interrupt Controller
  64. ; call them with:
  65. ; bl = IRQ number
  66. ; al = IRQ flag status (0 = enabled, 1= disabled)
  67. extrn _GetIRQMask:near, _SetIRQMask:near
  68.  
  69. ; 386 MANager type
  70. extrn   _386Man:byte
  71. ; possible values of _386Man
  72. IS_VCPI  = 0
  73.         ; VCPI server (i.e. EMM386)
  74. IS_DPMI  = 1
  75.         ; Usually Windows or OS/2
  76. IS_XMS   = 2
  77.         ; HIMEM.SYS
  78. IS_HARD  = 3
  79.         ; Nothing, we will have to go directly to hardware
  80.  
  81. ; CPU type
  82. extrn   _CPUPower:byte
  83. ; CPU class : 0=8086 , 1=186, 2=286, 3=386, 4=486, 5=586
  84. ; N.B. no info is told about the FPU (i.e 486 can be a 486DX or a 486SX)
  85.  
  86. ; routines to allocate memory
  87. ; IN: eax= size
  88. ;
  89. ; OUT: if CARRY_FLAG clear then 
  90. ;               eax = offset of allocated block (code32 relative)
  91. ;      else
  92. ;               not enough memory available
  93. ;
  94. ; _GetLoMem tries to allocate memory into dos ram (the first 640k)
  95. ; _GetHiMem tries to allocate memory into extended ram (beyound the 1st mega)
  96. ; _GetMem   tries first dos, then extended ram
  97. extrn   _GetMem:near, _GetLoMem:near, _GetHiMem:near
  98.  
  99. ; terminates program, sets text mode 03h and restores all interrupt handlers
  100. extrn   _Exit:near 
  101.  
  102. extrn   _OnExit:near ; add a subroutine to the code executed when _Exit 
  103.                      ; is called.
  104.                      ; EAX = subroutine offset
  105.                      ;       the subroutine must preserve the segment registers
  106.                      
  107. extrn   _MapPhysMem:near 
  108. ; Maps a physical memory block to a code32 relative offset
  109. ; This is useful to "map in" physical memory
  110. ; (i.e. the vram of a video card supporting linear addressing).
  111. ; It is supposed the memory block is NOT ALREADY MAPPED
  112. ; ABSOLUTELY DON'T TRY to use this function to tunnel thru the paging hardware
  113. ; and fuck the paging system, nasty things will happen if you try
  114. ; to do this.
  115. ; IN: eax = base address of physical memory block
  116. ;     edx = size of block to map
  117. ; OUT:
  118. ;     if CARRY CLEAR then
  119. ;               eax = code32 relative offset equivalent to phys. base address
  120. ;     else
  121. ;              mapping failed
  122. ;     end-if
  123. ;
  124. ; WARNING! Under VCPI a maximum of 4Mbytes can be allocated for direct mapping.
  125. ; This is wide enough for the most common uses
  126. ; but if you don't think so, please let me know.
  127.         
  128.  
  129.  
  130. CR = 13
  131. LF = 10
  132.  
  133. ; Virtual DMA services allocate data in the low memory heap
  134. ; (always reachable)
  135. ; and store a description of it into a "scatterlist"
  136. ; to let you "see" directly how pages are mapped
  137. ; (this is necessary to directly access the allocated region
  138. ;  on a page-by-page method that lets you "disable" the slow
  139. ;  and sometimes erratic dma-translation)
  140. ; the following dwords are POINTERS to the actual routines
  141. ; i.e. if you want to get dma info, perform:   CALL _DMAInfo
  142.  
  143. extrn _DMAInfo:dword
  144. ; out: carry clear if DMA support is present
  145.  
  146. extrn _DMAInit:dword
  147. ;Initializes the VDMA system
  148. ; out: Carry clear if OK
  149. ;      eax=number of dma channels
  150.  
  151. ; hook to virtual dma services or emulate 'em
  152. extrn _DMALock:dword
  153. ; Locks a DMA channel (disables automatic dma translation)
  154. ; this way it is possible to use the _DMASend and _DMAReceive functions
  155. ; and other tasks cannot use it
  156. ; IN:  EAX = channel number
  157. ; OUT: Carry set if error
  158.  
  159. extrn _DMAUnLock:dword
  160. ; Unlocks a DMA channel & re-enables automatic dma translation
  161. ; so other tasks can freely use it.
  162. ; (do this BEFORE program termination, or your system may hang)
  163. ; IN:  EAX = channel number
  164. ; OUT: Carry set if error
  165.  
  166. extrn _DMASend:dword
  167. ; Sends data TO a device using DMA
  168. ; EAX = channel, EBX = Physical mem ptr, ECX = Lenght in BYTES
  169. ; n.b.if you send/receive on a 16bit channel (4..7) remember to keep
  170. ;     address and byte count WORD ALIGNED
  171. ; Remember that it is better if send data in chunks 4k bytes
  172. ; starting dma buffers on page boundaries returned by _DMAMap
  173. ; (so you can just allocate a buffer using _DMAMap
  174. ;  without having to check is the various pages are "in sequence"
  175. ;  and you also don't have to check if the data block
  176. ;  "is between" a dma page block)
  177.  
  178. extrn _DMAReceive:dword
  179. ; Receives data FROM a device using DMA
  180. ; EAX = channel, EBX = Physical mem ptr, ECX = Lenght in BYTES
  181. ; n.b.if you send/receive on a 16bit channel (4..7) remember to keep
  182. ;     address and byte count WORD ALIGNED
  183. ; n.b./2 better if you use the pages allocated and mapped by a scatterlist
  184. ;        (you will probably fuck eveything up if you don't)
  185.  
  186. extrn _DMAMap:dword
  187. ; Allocates & initializes a VDMA ScatterList into low memory
  188. ; IN: EAX= Size of buffer
  189. ; OUT: if Carry Clear then
  190. ;         EAX = Ptr to Scatterlist, _LoMemBase Updated
  191. ;      else EAX= pointer to error string for 386Return
  192.  
  193. extrn _DMAUnMap:dword
  194. ; Frees a VDMA ScatterList  (but does not deallocate memory from low heap)
  195. ; do this when terminating your program.
  196. ; IN: EAX= ScatterList to unlock
  197. ;
  198.  
  199. ; Receives data FROM a device using DMA
  200. ; EAX = channel, EBX = Physical mem ptr, ECX = Lenght in BYTES
  201. ; n.b.if you send/receive on a 16bit channel (4..7) remember to keep
  202. ;     address and byte count WORD ALIGNED
  203. ; Remember that using the scatterlist you have to send data in chunks
  204. ; of up to 4k bytes (not a big problem to me, if you use dma to send
  205. ; voice data you HAVE to scatter it to perform software mixing)
  206.  
  207. ; ScatterList structure (returned by a call to _DMAMap )
  208. VDMA_PTR   = 0  ; dd code32 relative pointer
  209. VDMA_SIZE  = 4  ; dd size
  210. VDMA_OFS   = 8  ; dd offset (the current version uses low memory)
  211. VDMA_SEG   = 12 ; dw real mode offset (the current version uses low mem)
  212. VDMA_PAGES = 16 ; pages requested
  213. VDMA_USED  = 18 ; pages actually allocated  (use this to determine
  214.                 ; how many (code32,physical) address couples
  215.                 ; are present starting from VDMA_SCATS
  216. VDMA_SCATS = 20 ; start of "couples" of scattered page entries
  217. ; where the VDS server puts only page entries
  218. ; the VDMA system will put COUPLES of dwords
  219. ; (the first dword is the code32 relative
  220. ; offset of the page,the 2nd dword is the physical address you have to send
  221. ; to the dma hardware
  222. ; so at offset VDMA_SCATS    you find the code32 address of the first page
  223. ;          at  VDMA_SCATS+4  you find the equivalent PHYSICAL address
  224. ; and so on ...
  225.  
  226.  
  227. ; do not performs "smart" jump optimizations automatically
  228. ; (this is needed to avoid code size screw-ups)
  229. NOJUMPS
  230.  
  231. ; do not perform automatic "smart" optimization, so nothint harmful
  232. ; will happen to some critical code sequences
  233. NOSMART
  234.